home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / mosmllib / Process.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  517 b   |  29 lines  |  [TEXT/R*ch]

  1. (* Process *)
  2.  
  3. type status = int
  4.  
  5. val success : status = 0;
  6. val failure : status = ~1;
  7.  
  8. prim_val system : string -> status = 1 "sml_system";
  9.  
  10. local
  11.     prim_val getenv_ : string -> string = 1 "sys_getenv";
  12. in
  13.     fun getEnv s = 
  14.     (SOME (getenv_ s)) handle _ => NONE
  15. end
  16.  
  17. val terminate = BasicIO.exit;
  18.  
  19. local 
  20.     val exittasks = (ref []) : (unit -> unit) list ref
  21. in 
  22.     fun atExit newtask =
  23.     exittasks := newtask :: !exittasks;
  24.     fun exit status =
  25.     (List.app (fn f => f ()) (!exittasks);
  26.     terminate status);
  27. end
  28.  
  29.